/*
 * Copyright (c) 2018, ZeeSec Technologies. All rights reserved.
 * ZeeSec PROPRIETARY/CONFIDENTIAL.
 */

package springtest.springWebSocket;

import java.util.Map;

import javax.websocket.Session;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

import com.google.common.cache.Cache;

/**
 * @author ZhiQiang Chen
 * @date 2018-12-03 11:09:48
 */
@Configuration
public class CustomWebSocketInterceptor extends HttpSessionHandshakeInterceptor {
    private volatile static Cache<String, Session> webSocketSessionCache;
    private static long sessionExpireTime;

    @Override
    public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
            Map<String, Object> attributes) throws Exception {
        boolean beforeHandshake = super.beforeHandshake(request, response, wsHandler, attributes);
        // String sessionId =
        // attributes.get(HTTP_SESSION_ID_ATTR_NAME).toString();
        return beforeHandshake;
    }

    @Override
    public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
            Exception ex) {
        super.afterHandshake(request, response, wsHandler, ex);
    }

}
